package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.db.domain.DevicesOrder;
import org.linlinjava.litemall.db.enums.OrderStatus;
import org.linlinjava.litemall.db.service.DevicesOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wx/device/orders")
public class DevicesOrderController {

    @Autowired
    private DevicesOrderService orderService;

    @PostMapping
    public DevicesOrder createOrder(@RequestBody DevicesOrder order) {
        return orderService.createOrder(order);
    }

    @GetMapping("/{id}")
    public DevicesOrder getOrder(@PathVariable Integer id) {
        return orderService.getOrderById(id);
    }

    @PatchMapping("/{id}/status")
    public void updateStatus(@PathVariable Integer id, @RequestParam OrderStatus status) {
        orderService.updateOrderStatus(id, status);
    }
}
